package com.tjetc.dao;

import com.tjetc.entity.Order;
import com.tjetc.entity.view.MerchantOrderDay;
import com.tjetc.model.OrderMerchantUser;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/*
 * 订单的增删改查
 * */
public interface OrderMapper {
    //下单 or 查单
    //用户下单
    int add(Order order);

    //查询订单
    Order selectByOrderId(int orderId);

    //用户查询所有订单
    List<Order> selectByUserId(int userId);

    List<Order> selectWaitPay(int userId);

    List<Order> selectWaitArrive(int userId);

    List<Order> selectWaitRemark(int userId);

    List<Order> selectAfterPay(int userId);

    List<Order> selectUnaccomplished(int userId);

    List<Order> selectRefund(int userId);

    //商家查询所有本店商品订单
    List<Order> selectAllByMerchantId(int merchantId);

    //商家查询某一菜品所有订单
//    List<Order> selectDishByMerchantId(int merchantId,int dishId);
    //删除订单
    int delete(int id);

    List<OrderMerchantUser> selectAllByOrder(Order order);

    Long countTodayOrders(LocalDateTime time);

    Long countTodayFinishOrders(LocalDateTime time);

    BigDecimal countTodayOrderMoney(LocalDateTime time);

    BigDecimal getTodayMerchantMoney(Integer merchantId, LocalDateTime time);

    List<MerchantOrderDay> getMerchantOrderByTodayMoney(LocalDateTime time);

    // 列出今日所有的订单
    List<Order> getOrderByDayTime(LocalDateTime time, Integer merchantId);

    // 列出指定时间内的订单
    List<Order> getOrderByStartTimeAndEndTime(LocalDateTime start, LocalDateTime end);

    // 列出指定月内所有的订单
    List<Order> getOrderByMonthTime(LocalDateTime time);

    //获取制定时间，制定id的店家的总单数
    Integer getMonthlyOrderNums(LocalDateTime start, LocalDateTime end, Integer MerchantId);

    //获取制定时间，制定id的店家的总金额
    BigDecimal getMonthlyOrderAmount(LocalDateTime start, LocalDateTime end, Integer MerchantId);

    //更改id号订单的状态位status
    Integer changeOrderStatus(@Param("id") Integer id, @Param("status") Integer status);

    Integer chageOrderCheckoutDay(int id, LocalDateTime time);

    Integer update(Order order);

    Order selectByNumber(String number);

    List<Order> selectNoPayAndByEndTime(@Param("time") LocalDateTime time);
}
